﻿using UnityEngine;
using System.Collections.Generic;
using System.Collections;
using System;

public class test : MonoBehaviour {

	// Use this for initialization
	void Start () {
       
	}

    public void RunActionDelay(float time, Action ac)
    {
        StartCoroutine(DelayRun(time, ac));
    }

    IEnumerator DelayRun(float time, Action ac)
    {
        yield return new WaitForSeconds(time);
        if (ac != null)
        {
            ac.Invoke();
        }
    }

    public bool invoke { get; set; }
	// Update is called once per frame
	void Update () {
        if (!invoke)
        {
            RunActionDelay(3f, Play);
            invoke = true;
        }
	}

    void Play()
    {
        Debug.Log("qweqweqweqwewq"); 
    }
}
